# coding: utf-8

# 1.字典
# 创建一个字典，包含 one、two、three 三个键
# 对应的值分别为 1，2，3
data = {'one':1, 'two':2, 'three':3}
# 将 two 键对应的值改为 4
data['two'] = 4
print(data)

# 2.统计下这段文字里，不同单词出现的次数
# Beautiful is better than ugly Explicit is better than implicit Simple is better than complex
# Complex is better than complicated Flat is better than nested Sparse is better than dense
l = ('Beautiful is better than ugly Explicit is better than implicit Simple is better than complex Complex is better than complicated Flat is better than nested Sparse is better than dense')
i = l.split()       # 切割列表
j = {}      # 创建空字典
for k in i:     # 用k遍历列表
    if k in j:      # 在用k遍历字典查重
        j[k] += 1       # 有就加1
    else:
        j[k] = 1        # 没有重复就添加
for k in j:     # 重新遍历一遍字典用来输出
    print(k, j[k])      # 输出 键和值